package com.sh.weblogspringboot.common.config;

import com.baomidou.mybatisplus.core.injector.AbstractMethod;
import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector;
import com.baomidou.mybatisplus.core.metadata.TableInfo;
import com.baomidou.mybatisplus.extension.injector.methods.InsertBatchSomeColumn;

import java.util.List;

/**
 * @author songHai
 * @Classname InsertBatchSqlInjector
 * @Description 添加 SQL 注入器
 * @Date 2025/4/8 23:37
 */
public class InsertBatchSqlInjector extends DefaultSqlInjector {

    @Override
    public List<AbstractMethod> getMethodList(Class<?> mapperClass, TableInfo tableInfo) {
        // super.getMethodList()保留Mybatis Plus自带的方法
        List<AbstractMethod> methodList = super.getMethodList(mapperClass, tableInfo);

        // 添加自定义方法：批量插入，方法名为：insertBatchSomeColumn
        methodList.add(new InsertBatchSomeColumn());

        return methodList;
    }
}
